package com.eurekaconsumerfeign;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

//将作为负载均衡客户端
@EnableDiscoveryClient //将当前应用加入到服务治理体系中
@SpringBootApplication
public class EurekaConsumerApplication {

	//用来发起真正的REST请求
	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	public static void main(String[] args) {
		SpringApplication.run(EurekaConsumerApplication.class, args);
		//1.x版是SpringApplicationBuilder(Application.class).web(true).run(args);
		//2.x版改成了SpringApplicationBuilder(Application.class).web(WebApplicationType webApplicationType).run(args);
		//其中web(WebApplicationType webApplicationType)不写的话默认从classpath加载
		//new SpringApplicationBuilder(EurekaConsumerApplication.class).run(args);
	}

}
